
<?php
session_start();
require_once '../models/Users.php';
$msg="";
$menuID= $_REQUEST['menuID'];
$menu	= Users::getMenuInfo($menuID);
if(isset($_POST['btn_submit'])){
	$menuName=$_POST["menuName"];
	$link=$_POST["link"];
	$newPageMenu=$_POST["newPageMenu"];

	$isParent=$_POST["isParent"];
	$parentID=$_POST["parentID"];
	$orderby=$_POST["orderby"];
	//$isPublished=$_POST["isPublished"];
	if(isset($_POST["isPublished"])){
		$isPublished="1";
	}else
	{
	$isPublished="0";
	}
	$re=Users::updateMenuAdmin($menuID,$menuName,$link,$newPageMenu,$isParent,$parentID,$orderby,$isPublished);
	if($re){
		$mgs="Cập nhật thành công!";
		//$page="update_menuAdmin.php?menuID=".$menuID;
		$page="ql_menuAdmin.php";
		Users::redirectTo($page);
	}else $mgs="Cập nhật thất bại !!!";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Cập nhật thông tin tài khoản</title>
<?php include '../admin/_meta.php';?>
</head>
<body>
<form method="post" action="update_menuAdmin.php?menuID=<?php echo $menuID;?>">
	<div id="firstLine">
		<div id="top-bar">
		<?php include '_top_bar_admin.php';?>
		</div>
	</div>
	<div id="container">
		<div id="header">
			<?php include '_menu_admin.php';?>
		</div>
		<div id="center">

			<div id="table-user">
			<table id="table-user-table">
					<tr>
						<td>Menu ID</td>
						<td><input type="text" name="menuID" value="<?php echo $menu["menuID"];?>" disabled="disabled"></td>
					</tr>
					<tr>
						<td>Menu name</td>
						<td><input type="text" name="menuName" value="<?php echo $menu["menuName"];?>" /></td>
					</tr>
					<tr >
						<td>Link</td>
						<td><input type="text" name="link" value="<?php echo $menu["link"];?>" /></td>
					</tr>
					<tr>
						<td>New page menu</td>
						<td>
							<select name="newPageMenu" >
							<option value="0">No</option>
							<option value="1">Yes</option></select>

						</td>
					</tr>
					<tr>
						<td>Is parent</td>
						<td><input type="text" name="isParent" value="<?php echo $menu["isParent"];?>" /></td>
					</tr>
					<tr>
						<td>Parent ID</td>
						<td><input type="text" name="parentID" value="<?php echo $menu["parentID"];?>" /></td>
					</tr>
					<tr>
						<td>Order</td>
						<td><input type="text" name="orderby" value="<?php echo $menu["orderby"];?>" /></td>
					</tr>
					<tr>
						<td>Is Published</td>
					<?php //<td><input type="text" name="isPublished" value="<?php echo $menu["isPublished"];" /></td>?>
						
						<?php 
							if($menu["isPublished"]==1){
								echo "<td><input type='checkbox' checked='check' name='isPublished'></td>";
							}else{
								echo "<td><input type='checkbox' name='isPublished' ></td>";
							}
						?>
					</tr>
					<tr>
						<td><input type="submit" name="btn_submit" value="Update" class="btn_submit"></td>
						<td><a href="ql_menuAdmin.php"><input type="button" name="button" value="Reset" class="btn_submit"></a></td>
					</tr>
					<tr>
						<td colspan="2"><?php if(isset($_POST['btn_submit'])) echo $mgs; ?></td>
					</tr>
					<?php Users::listMenuAdmin();?>
				</table>
			</div>
			</div>
		</div>
	</div>
	</div>
	<div>
		<?php include '_footer_admin.php';?>
	</div>
</form>
</body>
</html>
				
				
